package com.zhou.eb.web;

import com.zhou.eb.model.EbNews;
import com.zhou.eb.model.EbProductCategory;
import com.zhou.eb.service.EbNewsService;
import com.zhou.eb.service.EbProductCategorySercie;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/news")


public class NewsController {
    @Autowired
    private EbNewsService ebNewsService;

     @Autowired
    EbProductCategorySercie ebProductCategorySercie;
     @RequestMapping("/detail")

     public String detail(Model model,Integer enId){
         System.out.println("+++++++++++++++++++浏览器点击某条新闻+++++++++++++++++++++++++++"+enId);
         EbNews ebNewsDetail =ebNewsService.detail(enId);

         Map<String, List<EbProductCategory>> categoryMap=ebProductCategorySercie.selectBigAndSmallCate();

         model.addAttribute("detail",ebNewsDetail);
         model.addAttribute("categoryMap",categoryMap);
         return "news-view";

     }



}
